<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.js"></script>
</head>

<body>
    <div id="app">

        <!-- 
            不同的是带有v-show的元素始终会被渲染并且保留在don中，
            v-show只是简单得切换css property display
         -->
        <button @click="type=1">新闻</button>
        <button @click="type=2">音乐</button>
        <button @click="type=3">娱乐</button>

        <div v-show="type===1">
            <h2>新闻...</h2>
            <input type="text" />
        </div>

        <div v-show="type===2">
            <h2>音乐...</h2>
            <input type="text" />
        </div>

        <div v-show="type===3">
            <h2>娱乐...</h2>
            <input type="text" />
        </div>
    </div>
    <script>
        Vue.config.productionTip = false;

        const vm = new Vue({
            el: "#app",
            data() {
                return {
                    type: 1,
                }
            }
        })
    </script>
</body>

</html>